package AbstractFactoryMethodPattern.FactoryMethodExample.cellphone;

import AbstractFactoryMethodPattern.FactoryMethodExample.cpu.AppleCpu;
import AbstractFactoryMethodPattern.FactoryMethodExample.cpu.CpuFactory;
import AbstractFactoryMethodPattern.FactoryMethodExample.cpu.QualcommCpu;
import AbstractFactoryMethodPattern.FactoryMethodExample.framework.Factory;
import AbstractFactoryMethodPattern.FactoryMethodExample.framework.Product;

public class CellPhoneFactory extends Factory {
    @Override
    public Product createProduct(String type) {
        Product cellPhone;
        Product cpu;

        Factory cpuFactory = new CpuFactory();
        switch (type) {
            case "iphone4s":
                cpu = cpuFactory.create("A11");
                cellPhone = new iPhone("iphone4s", (AppleCpu) cpu);
                break;
            case "Galaxy10":
                cpu = cpuFactory.create("X820");
                cellPhone = new Galaxy("Galaxy10", (QualcommCpu) cpu);
                break;
            default:
                cellPhone = null;
        }
        return cellPhone;
    }

    @Override
    public void registerProduct(Product product) {

    }
}
